package com.sun.module_hot.ui.animation

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.google.auto.service.AutoService
import com.sun.module_common.serviceinterface.hot.AnimationService
import com.sun.module_common.widget.AnimationView
import com.sun.module_common_res.R

/**
 *@author:sunc
 *@time :2025/8/18 10:18
 *@desc: 描述
 */
@AutoService(AnimationService::class)
class AnimationServiceImpl : AnimationService {

    override fun getService(navCtrl: NavHostController): @Composable () -> Unit {
        return { SimpleScreen() }
    }
}

//https://lottiefiles.com/  动画图片案例地址
@Composable
fun SimpleScreen(modifier: Modifier = Modifier) {

    LazyColumn(modifier = modifier.fillMaxSize()) {
        item {
            //Raw
            /**
             *  iterations 重复次数 默认1次， 如果想要永远重复可以设置为 LottieConstants.IterateForever，其实就是 Integer.MAX_VALUE。
             */
            AnimationView(spec = LottieCompositionSpec.RawRes(resId = R.raw.food))
        }

        item {
            //Asset
            AnimationView(spec = LottieCompositionSpec.Asset(assetName = "working.json"))
            AnimationView(spec = LottieCompositionSpec.Asset(assetName = "cryptoload.json"))
            AnimationView(spec = LottieCompositionSpec.Asset(assetName = "loader.json"))
            AnimationView(spec = LottieCompositionSpec.Asset(assetName = "profile.json"))
            AnimationView(spec = LottieCompositionSpec.Asset(assetName = "success.json"))
        }

        item {
            //网络动画
            AnimationView(spec = LottieCompositionSpec.Url(url = "https://pic.rmb.bdstatic.com/bjh/news/bd14f95493ec8f978cfb23e287438598.json"))
        }
    }


}

